﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PersonaLibrary.Search;
using PersonaLibrary.Data;

namespace PersonaLibrary.Commands.LoadWithCommands
{
	public class LoadEmployeeWithNote : CommandBase
	{
		public override bool CanExecute(object parameter)
		{
			return parameter is Note;
		}

		public override void Execute(object parameter)
		{
			Filter filter = new Filter("EmployeeWithNote", typeof(Employee))
			                	{
									DisplayName = string.Format("Сотрудники в \"{0}\"", ((Note)parameter).Name),
			                		FuncFilter = x => ((Employee) x).EmployeeNoteLinks.Any(note => note.NoteId == ((Note) parameter).Id)
			                	};
			((App) App.Current).Filter = filter;
		}
	}
}
